package com.element5th.shop.servlet.good;

import java.io.IOException;
import java.io.PrintWriter;
import java.util.List;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import com.element5th.comm.ServletUtil;
import com.element5th.shop.comm.DaoFactory;
import com.element5th.shop.dao.good.IAdminGoodDao;
import com.element5th.shop.dto.BaseDto;

/**
 * Servlet implementation class GetBigClassList
 */
@WebServlet("/page/admin/page/class_list")
public class AdminClassList extends HttpServlet {
	private static final long serialVersionUID = 1L;
       
    /**
     * @see HttpServlet#HttpServlet()
     */
    public AdminClassList() {
        super();
    }

	/**
	 * @see HttpServlet#service(HttpServletRequest request, HttpServletResponse response)
	 */
	protected void service(HttpServletRequest request, HttpServletResponse response) 
			throws ServletException, IOException {
		Integer bigClassId = ServletUtil.getInteger(request, "bigClassId");
		PrintWriter writer = response.getWriter();
		if(bigClassId != 0){
			IAdminGoodDao dao = DaoFactory.getAdminGoodDao();
			List<BaseDto> list = dao.getClassList(bigClassId);
			
			for (BaseDto baseDto : list) {
				writer.println("<option value='" + baseDto.getGoodClass().getClassId() + "'>"
						+ baseDto.getGoodClass().getClassName() +"</option>");
			}
		} else {
			writer.print("");
		}
	}

}
